package cn.valorin.event;

import static cn.valorin.configuration.languagefile.MessageSender.sm;

import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;

import cn.valorin.Main;
import cn.valorin.item.BeanSeed;
import cn.valorin.item.RiceSeed;
import cn.valorin.via.Via;

public class SeedGainEvent implements Listener {
	@EventHandler
	public void gain(BlockBreakEvent e) {
		if (e.getBlock().getType().equals(Via.long_grass)) {
			if (Math.random() <= Main.getInstance().getConfig().getDouble("SeedDropChance.Bean")) {
				e.getBlock().getWorld().dropItem(e.getBlock().getLocation(), BeanSeed.get(e.getPlayer()));
				sm("&a你获得了一个豆种",e.getPlayer());
			}
			if (Math.random() <= Main.getInstance().getConfig().getDouble("SeedDropChance.GlutinousRice")) {
				e.getBlock().getWorld().dropItem(e.getBlock().getLocation(), RiceSeed.get(e.getPlayer()));
				sm("&a你获得了一个糯稻种子",e.getPlayer());
			}
		}
	}
}
